from abc import ABC, abstractmethod
import torch

class MetricBase(ABC):
    def __init__(self):
        self.total = 0
        self.value = 0.
    
    def reset(self):
        self.totoal = 0
        self.value = 0
    
    @torch.no_grad()
    def __call__(self, y_true, y_pred):
        self.total +=1 
        y_pred.to(y_true.device)
        self.value += self.compute(y_true, y_pred)
    
    @abstractmethod
    def compute(self, y_true, y_pred):
        pass
    
    @abstractmethod
    def summary(self):
        pass